﻿namespace FFF.Test
{
    using System;
    using System.IO;
    using System.Linq;
    using System.Reflection;
    using System.Text;
    using System.Threading.Tasks;
    using Abp.Application.Services;
    using Abp.AspNetCore.Runtime.Cache;
    using Microsoft.AspNetCore.Authentication.JwtBearer;
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.AspNetCore.Http;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.IdentityModel.Tokens;
    using StackExchange.Profiling.Storage;
    using Swashbuckle.AspNetCore.Swagger;
    using Swashbuckle.AspNetCore.SwaggerGen;
    using FFF.Test.Util.Consts;

    /// <summary>
    /// 配置文档生成
    /// </summary>
    public static class MiniProfilerConfigurer
    {
        /// <summary>
        /// 配置文档生成
        /// </summary>
        /// <param name="services">程序的服务对象</param>
        /// <param name="configuration">程序的配置对象</param>
        /// <param name="env">环境节点</param>
        public static void ConfigureServices(IServiceCollection services, IConfiguration configuration, IHostingEnvironment env)
        {
            //if (env.IsProduction() || env.IsStaging())
            //{
            //    services.AddMiniProfiler(options =>
            //    {
            //        options.PopupRenderPosition = StackExchange.Profiling.RenderPosition.BottomLeft;
            //        options.PopupShowTimeWithChildren = true;
            //        options.ResultsAuthorize = request => request.HttpContext.Session.GetUserInfo()?.UserIsAdmin == 1;
            //        options.ShouldProfile = request => request.Path.Value.Contains("/api/services/app");
            //        options.RouteBasePath = "/profiler";
            //        options.Storage = new SqlServerStorage(AppConfigConsts.LogConStr);
            //    }).AddEntityFramework();
            //}

        }

        /// <summary>
        /// 文档的配置
        /// </summary>
        /// <param name="app">app环境</param>
        /// <param name="env">env的环境</param>
        public static void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            //if (env.IsProduction() || env.IsStaging())
            //{
            //    app.UseMiniProfiler();
            //}

        }
    }
}
